namespace CaltechSoft.Service.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class New : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.PoItems",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Quantity = c.Int(nullable: false),
                        UnitPrice = c.Long(nullable: false),
                        EquipmentId = c.Int(nullable: false),
                        QuoteId = c.Int(nullable: false),
                        CreatedBy = c.String(maxLength: 128),
                        CreatedDate = c.DateTime(),
                        UpdatedDate = c.DateTime(),
                        UpdatedBy = c.String(),
                        Po_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Equipment", t => t.EquipmentId, cascadeDelete: true)
                .ForeignKey("dbo.Poes", t => t.Po_Id)
                .ForeignKey("dbo.AspNetUsers", t => t.CreatedBy)
                .Index(t => t.EquipmentId)
                .Index(t => t.CreatedBy)
                .Index(t => t.Po_Id);
            
            CreateTable(
                "dbo.Poes",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ServiceCharges = c.Long(nullable: false),
                        Tax = c.Single(nullable: false),
                        QuoteNumber = c.String(),
                        PoNumber = c.String(),
                        CompanyId = c.Int(nullable: false),
                        SalesmanId = c.String(maxLength: 128),
                        GrandTotal = c.Decimal(nullable: false, precision: 18, scale: 2),
                        CalibrationDate = c.DateTime(),
                        Note = c.String(),
                        CreatedBy = c.String(maxLength: 128),
                        CreatedDate = c.DateTime(),
                        UpdatedDate = c.DateTime(),
                        UpdatedBy = c.String(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Customers", t => t.CompanyId, cascadeDelete: true)
                .ForeignKey("dbo.AspNetUsers", t => t.SalesmanId)
                .ForeignKey("dbo.AspNetUsers", t => t.CreatedBy)
                .Index(t => t.CompanyId)
                .Index(t => t.SalesmanId)
                .Index(t => t.CreatedBy);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.PoItems", "CreatedBy", "dbo.AspNetUsers");
            DropForeignKey("dbo.Poes", "CreatedBy", "dbo.AspNetUsers");
            DropForeignKey("dbo.Poes", "SalesmanId", "dbo.AspNetUsers");
            DropForeignKey("dbo.PoItems", "Po_Id", "dbo.Poes");
            DropForeignKey("dbo.Poes", "CompanyId", "dbo.Customers");
            DropForeignKey("dbo.PoItems", "EquipmentId", "dbo.Equipment");
            DropIndex("dbo.Poes", new[] { "CreatedBy" });
            DropIndex("dbo.Poes", new[] { "SalesmanId" });
            DropIndex("dbo.Poes", new[] { "CompanyId" });
            DropIndex("dbo.PoItems", new[] { "Po_Id" });
            DropIndex("dbo.PoItems", new[] { "CreatedBy" });
            DropIndex("dbo.PoItems", new[] { "EquipmentId" });
            DropTable("dbo.Poes");
            DropTable("dbo.PoItems");
        }
    }
}
